#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMouseEvent>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void mousePressEvent(QMouseEvent *e)
    {
        if(e->button() == Qt::LeftButton) //若鼠标左键被按下
        {
            moveFlag = true;
            move_point = e->pos();//鼠标相对于窗体的位置（或者使用event->globalPos() - this->pos()）
        }
    }
    void mouseReleaseEvent(QMouseEvent *e)
    {
        moveFlag = 0;
    }
    void mouseMoveEvent(QMouseEvent *event)
    {
        if(moveFlag)
        {
            QPoint move_pos = event->globalPos(); //鼠标相对于屏幕的位置
            this->move(move_pos - move_point); //移动主窗体位置
        }
    }
    void showHintLabel(QWidget *parent,
                              QString strText,
                              QString strFontSize = "16px",
                              QString strColor = "#ffffff",
                              QString strBgColor = "#202020"); //一个提示便签  会淡化消失
private slots:
    void on_pushButton_clicked();

    void on_pushButton_cance_clicked();

    void on_checkBox_time_clicked();

    void on_checkBox_count_clicked();

private:
    Ui::MainWindow *ui;
    bool moveFlag;
    QPoint move_point;
    QString caculateRegister(QString serial, QByteArray keyData);
    QString HexToHexstr(const QByteArray hex);
};

#endif // MAINWINDOW_H
